package com.xuecheng.content.controller;

import com.xuecheng.commons.model.dto.TeacherDto;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.content.domain.CourseTeacher;
import org.springframework.web.bind.annotation.*;
import com.xuecheng.content.service.CourseTeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * 课程-教师关系表前端控制器
 * </p>
 *
 * @author itheima
 */
@Slf4j
@RestController
public class CourseTeacherController {

    @Autowired
    private CourseTeacherService  courseTeacherService;


    // 添加或修改教师
    @PostMapping("/courseTeacher")
    public ResponseResult saveTeacher(@RequestBody TeacherDto dto){
        return courseTeacherService.saveTeacher(dto);
    }

    // 教师查询
    @GetMapping("/courseTeacher/list/{id}")
    public ResponseResult<CourseTeacher> findTeacher(@PathVariable("id") Long courseId){
        return courseTeacherService.findTeacher(courseId);
    }

    // 删除教师
    @DeleteMapping("/courseTeacher/course/{id}/undefined")
    public ResponseResult deleteById(@PathVariable("id") Long id){
        return courseTeacherService.deleteById(id);
    }

}
